#!/bin/bash

# export PHPENV=`php -v 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $2} ' | awk -F"." '{print $1}'`
# which php
# pwd 
# /opt/codes/node1/application/libraries/upUserStatuds
# ls -la
# /opt/codes/node1/application/libraries/upUserStatuds/command.sh
# 
# vim /opt/codes/node1/application/libraries/upUserStatuds/command.sh
# 
# sh command.sh upUserStatus -n bcSubNum -bid 2o98u4603 -msg '值班数据处理2'
#
# 当前目录 simple_shell_gitee/shPhpParamMysql/sh
currentPath=$(cd $(dirname $0);pwd)
# PHP可执行文件的目录
## PHP=/usr/local/php/bin/php
PHP=/usr/local/bin/php
# 应用的目录 simple_shell_gitee/shPhpParamMysql
APPPATH=$(dirname $currentPath)
# APPPATH=/opt/lampp/crm/application/
GLOBALLOGPATH=/data/applogs/welife-http-service

echo '=currentPath='$currentPath

echo '=PHP='$PHP

echo '=APPPATH='$APPPATH

echo '-GLOBALLOGPATH-'$GLOBALLOGPATH


export COMMAND_SHELL="command.sh"

TENV=$(echo $currentPath|cut -d '/' -f 3)

echo '-TENV-'$TENV

case $TENV in
    dev) export APPENV=dev;;
    beta) export APPENV=beta;;
    pre) export APPENV=pre;;
    *) export APPENV=pro;;
esac

cmd=$1
params=$@

# currentPhpPath=${currentPath}
currentPhpPath="${APPPATH}/php"

echo '=COMMAND_SHELL='$COMMAND_SHELL

echo '-cmd-'$cmd

echo '=params='$params

if [ "$cmd" == "upUserStatus" ] || [ "$cmd" == "task" ] || [ "$cmd" == "tool" ]; then
	$PHP ${currentPhpPath}/${cmd}.php ${params#${cmd} }
    # echo '====>>'"$PHP ${currentPhpPath}/${cmd}.php ${params#${cmd} }"
fi
